package com.android.image;

import java.io.File;
import java.util.Date;


import android.app.Application;
import android.content.Context;
import android.os.Environment;
import android.os.Handler;
import android.widget.Toast;

/**
 * 
 * 
 */
public class VGongyiApp extends Application {
	public static Context context;
	private static Handler handler;
	private static String mVersion;
	public static String DEFAULT_SDCARD_PATH = null;
	public final static int SUBSCIBE_MAX = 15;
    public final static int COLLECT_MAX = 15;
	public final static int REMIND_MAX = 15;
	public final static int HISTORY_MAX = 15;
	private static long uiThreadID;
	public static String mCurDate = null;// 当前的真正日期
	public static TPManager mTpManager;
    private static Date now = null;//server time
    
    public static int mDuration;
    public static int mCurrentPosition;
    
	

	public static float mDisplayScale;

	@Override
	public void onCreate() {
		super.onCreate();
		context = getBaseContext();
		handler = new Handler();
		uiThreadID = Thread.currentThread().getId();
		DEFAULT_SDCARD_PATH = getSDPath();
		mVersion = AppUtils.getVersionName(getApplicationContext());
		mTpManager = TPManager.getInstance();

		mDisplayScale = context.getResources().getDisplayMetrics().density;
        
	}

	public static void showToast(final int resId) {
		handler.post(new Runnable() {
			@Override
			public void run() {
				Toast.makeText(context, resId, Toast.LENGTH_SHORT).show();
			}
		});
	}

	public static void showToast(final String text) {
		handler.post(new Runnable() {
			@Override
			public void run() {
				Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
			}
		});
	}

	public static String getVersion() {
		return mVersion;
	}

	private String getSDPath() {
		File sdDir = null;
		if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
			sdDir = Environment.getExternalStorageDirectory();
		}
		return sdDir == null ? null : sdDir.toString()+ VGongyiSetting.CACHE_ROOT_DIR;
	}

    public static Date getNow() {
        return now;
    }

    public static void setNow(Date now) {
        VGongyiApp.now = now;
    }
}
